using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCounterAttactState : PlayerState
{
    public PlayerCounterAttactState(Player _player, PlayerStateMachine _stateMachine, string _animBoolName) : base(_player, _stateMachine, _animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        stateTimer = player.counterAttactDuration;
        player.anim.SetBool("SuccessfulCounter", false);
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void update()
    {
        base.update();
        Collider2D[] colliders = Physics2D.OverlapCircleAll(player.attackCheck.position, player.attackRadius);
        foreach (var hit in colliders)
        {
            if (hit.GetComponent<Enemy>() != null)
            {
                if (hit.GetComponent<Enemy>().CanBeStunned())
                {
                    stateTimer = 10f;
                    player.anim.SetBool("SuccessfulCounter", true);
                    player.skill.parrySkill.UseSkill();
                    player.skill.parrySkill.MakeMirageOnParry(hit.transform);


                }

            }
        }
        if (stateTimer < 0 || triggerCalled)
        {
            stateMachine.ChangeState(player.idleState);

        }
    }
}
